package com.czxy.controller;

import com.czxy.pojo.Specification;
import com.czxy.pojo.group.BaseResult;
import com.czxy.service.SpecificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 规格选项Controller
 * @author Liuyunqin 17674029449@163.com
 * @date 2018/12/25 15:10
 */
@RestController
@RequestMapping
public class SpecificationController {
    @Autowired
    private SpecificationService specificationService;

    /**
     * 根据三级分类id查询对应的规格选项
     * @param catid
     * @return
     */
    @GetMapping("specifications/{catid}")
    public ResponseEntity<Object> findSpecificationByCatId(@PathVariable("catid") Integer catid){
        List<Specification> findByCid = specificationService.findSpecificationByCatId(catid);
        BaseResult baseResult = new BaseResult(0,"成功",findByCid);
        return ResponseEntity.ok(baseResult);
    }
}
